package com.app.tools;

import org.jasypt.util.text.BasicTextEncryptor;

/**
 * 属性文件值加密解密
 */
public class ToolJasypt {
	private static BasicTextEncryptor textEncryptor = null;

	public static String decrypt(String encryptedMessage, String key) {
		textEncryptor = new BasicTextEncryptor();
		textEncryptor.setPassword(key);
		return textEncryptor.decrypt(encryptedMessage);
	}
	
	public static String encrypt(String decryptMessage, String key) {
		textEncryptor = new BasicTextEncryptor();
		textEncryptor.setPassword(key);
		return textEncryptor.encrypt(decryptMessage);
	}
	
	public static void main(String[] args) {
		String es = ToolJasypt.encrypt("abcdefghijklmn", "abcd");
		System.out.println(es);
		String ds = ToolJasypt.decrypt(es, "abcd");
		System.out.println(ds);
	}
}
